# 3-3 匹配括号
from pythonds.basic import Stack;


def parChecker(sysmbolString):
    index = 0
    s = Stack()
    balanced = True
    while index < len(sysmbolString) and balanced:
        symbol = sysmbolString[index]
        if symbol == "(":
            s.push(symbol)
        else:
            if s.isEmpty():
                balanced = False
            else:
                s.pop()
        index += 1
    if balanced and s.isEmpty():
        return True
    else:
        return False


sysmbolString = "(()))"
print(parChecker(sysmbolString))
